import React, { Component } from 'react'
import { Switch, Redirect, Route } from 'react-router-dom'
import ReactLoadable from 'react-loadable'

//import Home from '../components/Home/Home'

var Home = ReactLoadable({
    loader: () => import('../components/Home/Home'),
    loading: () => <div className="loading">loading...</div>
});

var Allgood = ReactLoadable({
    loader: () => import('../components/Allgood/Allgood'),
    loading: () => <div className="loading">loading...</div>
});

var Collect = ReactLoadable({
    loader: () => import('../components/Collect/Collect'),
    loading: () => <div className="loading">loading...</div>
});

var Detail = ReactLoadable({
    loader: () => import('../components/Detail/Detail'),
    loading: () => <div className="loading">loading...</div>
});


export default class Router extends Component {
    render() {
        return (
            <Switch>
                <Route path="/home" component={Home}></Route>
                <Route path="/allgood" component={Allgood}></Route>
                <Route path="/collect" component={Collect}></Route>
                <Route path="/detail" component={Detail}></Route>
                <Redirect to="/home"></Redirect>
            </Switch>
        )
    }
}
